/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once
#include "PacketBuilder6.h"

#include "MimicInfoPack.h"

class PacketBuilderEx6 : public PacketBuilder6
{
private:
	MimicInfoPack mimicInfoPack;

	///< Creates SYN packet options according to the OS that I try to mimic
	int BuildSynOptions(BYTE*);

	///< Build the content of an ICMP Echo packet's data according to the OS that I try to mimic
	int BuildIcmpEchoDataBuffer(BYTE*);

	MimicInfo mimicInfo;	///< used across the class to get data

public:
	PacketBuilderEx6(void);
	~PacketBuilderEx6(void);

	void SetMimic(MimicOS);

	bool BuildPackTcpSyn(
			in_addr6* srcAddrIn,		///< source address
			in_addr6* dstAddrIn,		///< destination address
			WORD wDP,					///< destination port
			DWORD dwSeq				    ///< sequence
		);

	bool BuildPackTcpFlat(
			in_addr6* srcAddrIn,		///< source address
			in_addr6* dstAddrIn,		///< destination address
			WORD wDP,					///< destination port
			DWORD dwSeq,			    ///< sequence
			DWORD dwAck,				///< acknowledge
			BYTE  bFlags				///< flags
		);

	bool BuildPackTcpFlatWithSrcPort(
			in_addr6* srcAddrIn,		///< source address
			in_addr6* dstAddrIn,		///< destination address
			WORD wSP,					///< source port
			WORD wDP,					///< destination port
			DWORD dwSeq,			    ///< sequence
			DWORD dwAck,				///< acknowledge
			BYTE  bFlags				///< flags
		);

	bool BuildPackUDPFlat(
			in_addr6* srcAddrIn,		///< source address
			in_addr6* dstAddrIn,		///< destination address
			WORD wDP					///< destination port
		);

	bool BuildPackIcmpEchoRequest(
			in_addr6* srcAddrIn,		///< source address
			in_addr6* dstAddrIn 		///< destination address
		);

	bool BuildPackIcmpEchoRequestWithUserData(
			in_addr6* srcAddrIn,		///< source address
			in_addr6* dstAddrIn, 		///< destination address
			BYTE* dataIn,				///< payload
			int sizeIn					///< payload's size
		);

	bool BuildPacketEmptyIPv6ProtoFlat(
			in_addr6* srcAddrIn,			///< source address
			in_addr6* dstAddrIn,			///< destination address
			BYTE      bNextHeaderIn		///< next header
		);
};
